var app = getApp();
Component({
    properties: {
        shopid: Number,
        cart: Object,
    },
    observers: {
        'cart': function (cart) {
            // 刷新购物车
            var self = this;
            var money = 0;
            var num = 0
            for (var i in cart.goodlist) {
                var item = cart.goodlist[i].list;
                for (var j = 0; j < item.length; j++) {
                    money += item[j].num * item[j].show_price * 1;
                    num += item[j].num*1
                }
            }
            self.setData({
                allmoney: money.toFixed(2) * 1,
                allnum: num.toFixed(2) * 1,
            });
        }
    },
    data: {
        isIPX: app.globalData.isIPX ? 1 : 0,
        allmoney: 0,
        allnum: 0,

    },
    options: {},
    methods: {
        showCart() {
            this.triggerEvent('showcart')
        },
        countit(){
            this.triggerEvent('countit')
        },
        count() {

        },
    }
});